package com.dream.base;

import android.app.Application;

import com.dream.base.tools.NetWorkUtil;


/**
 * Description: App's application should extend this class
 * @author: WangKunHui
 * date: 11/28/16 10:34 AM
 * <p>
 * Copyright©2016 by wang. All rights reserved.
 */
public abstract class BaseApplication extends Application {

    protected static BaseApplication instance;

    /**
     * App是否在前台
     */
    public static boolean isAppRunning = false;

    private int currentNetType = -1;

//    private OkHttpClient httpCline;

    public static BaseApplication getInstance() {
        return instance;
    }

    /**
     * current net connection type
     *
     * @return
     */
    public int getCurrentNetType() {
        return currentNetType;
    }

    /**
     * current net connection status
     *
     * @return
     */
    public boolean isNetConnection() {
        return currentNetType == NetWorkUtil.NET_NO_CONNECTION ? false : true;
    }

    @Override
    public void onCreate() {
        super.onCreate();

        instance = this;

        initHttp();

        currentNetType = NetWorkUtil.getConnectionType(this);

    }

    protected void initHttp() {

    }

}
